#include <stdio.h>
#include<malloc.h>
#define MaxSize 100

typedef struct my_stack
{
    int array[MaxSize];
    int top;
}my_stack;

void stack_init(my_stack* stack)
{
    stack = (my_stack*)malloc(sizeof(my_stack));
    stack->top = -1;
}

void stack_destroy(my_stack* stack)
{
    if(stack == nullptr)
    {
        return;
    }
    free(stack);
    stack = nullptr;
}

bool empty(my_stack* stack)
{
    if(stack->top == -1)
    {
        return true;
    }
    return false;
}

void push(my_stack* stack, int ele)
{
    if(stack->top == MaxSize - 1)
    {
        printf("容量已满");
        return;
    }
    stack->array[++(stack->top)] = ele;
}

int pop(my_stack* stack)
{
    if(empty(stack))
    {
        return -1;
    }
    int tmp = stack->array[(stack->top)];
    stack->top--;
    return tmp;
}

int get_top(my_stack* stack)
{
    if(stack->top == -1)
    {
        return -1;
    }
    return stack->array[(stack->top)];
}

int main()
{
    my_stack* stack;
    stack_init(stack);
    push(stack, 1);
    push(stack, 1);
    pop(stack);
    empty(stack);
    return 0;
}